package com.zwy.com.zwy.activti;

import org.activiti.engine.ProcessEngine;
import org.activiti.engine.ProcessEngines;
import org.activiti.engine.RuntimeService;
import org.activiti.engine.runtime.ProcessInstance;

/**
 * 启动流程实例
 * @author 天火
 * @className ActivitiRuntime
 *      影响到的表
 *          act_hi_actinst          已完成的活动信息
 *          act_hi_indentityLink    参与者信息
 *          act_hi_proinst          流程实例
 *          act_hi_taskinst         任务实例
 *          act_ru_execution        执行表
 *          act_ru_indentitylink    参与者信息
 *          act_ru_task             任务
 */
public class ActivitiRuntime {

    public static void main(String[] arg){

        // 1.得到ProcessEngine对象
        ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine();
        //2.得到RunService对象
        RuntimeService runtimeService = processEngine.getRuntimeService();
        //3.启动一个流程实例 需要使用流程的key
        ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("holiday");
        //4.输出流程实例
        System.out.println("流程定义Id：" + processInstance.getProcessDefinitionId());
        System.out.println("流程实例ID：" + processInstance.getId());
        System.out.println("当前活动Id：" + processInstance.getActivityId());

    }
}
